#!/usr/bin/env bash        
sh=/bin/sh
[ ! -z "/bin/bash" ] && sh=/bin/bash
shFile=a.sh
echo "#!$sh" > $shFile
i(){
sudo cat - >> $shFile <<'EK'
usage['hc']="使用tcp去下载http文件,没有安装curl 1host 2url [3:port]"
hc(){
    [ -z "$2" ] && echo ""
    local host=$1
    local url=$2
    local port=${3:-80}
    exec 123<>/dev/tcp/$host/$port
    echo -e "GET $url HTTP/1.1\r\nhost: $host\r\nConnection: close\r\n\r\n" >&123
    local file=/tmp/$host.txt
    _info "download file $file"
    cat <&123 > $file
    cat $file
}
EK
}
"$@"


